home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Reference & Presen…tion Library 2 (Reseller)
/
Apple R&P Lib Reseller v2.0.iso
/
3-Demos
/
HyperCard Demos
/
HyperMovies
/
CL⁄1
/
CL_1
/
background_2398.txt
< prev
next >
Wrap
Text File
|
1989-10-27
|
19KB
|
729 lines
-- background: 2398 from stack: in
-- bmap block id: 4274
-- flags: 4000
-- background id: 0
-- name: Region Cards
----- HyperTalk script -----
-- On opening any of the Region Cards, do the following:
-- Erase the bar chart, clear out previous data
-- Retrieve from the host, the current data for this region:
-- • sales representatives' names
-- • sales representatives' quotas
-- • sales representatives' sales to date
-- Calculate % of quota achieved to date
-- Draw the bar chart that compares the % for each rep
-- Store the data on the Data Card for this region
on RetrieveRegionData
global ConnectedToHost
if not inDebug() then
put regionNumber (the short name of this card) into regionNum
put "Region" && regionNum into dataCardName
set cursor to 4
show field "Status Backdrop"
show field "Status"
if ConnectedToHost is not true then
send "ConnectToVax" to bkgnd "Region Data"
if the result <> empty then
wait 120 ticks
put empty into field "Status"
hide field "Status Backdrop"
hide field "Status"
exit to HyperCard
end if
end if
send "GetDataForCard" && quote & dataCardName & quote to card dataCardName
put the short date && the time into bkgnd field "Time & Date"
DoGraph
put false into needRegionUpdate
end if
end RetrieveRegionData
on DoGraph
global barMargin,barWidth,sideMargin,botMargin
set cursor to watch
put empty into field "Status"
show field "Status Backdrop"
show field "Status"
put "Stand by… Creating the bar chart" into bkgnd field "Status"
put regionNumber (the short name of this card) into regionNum
put RegionalFigures(regionNum) into regionSubtotals
put RegionalPercents(regionNum) into regionPercents
put RegionalNames(regionNum) into regionReps
put RegionalRepNums(regionNum) into repNums
set lockScreen to true
put barMargin into margin
put item 4 of the rect of field "Status Backdrop" into graphStopsHere
put the number of items in repNums into dataCount
--adjust the frame
get rect of bkgnd btn "Regional Chart"
put item 1 of rect of bkgnd btn "Regional Sales YTD" - 10 into rLimit
put rLimit - (barWidth * dataCount) - (sideMargin * (dataCount + 1)) into lLimit
put lLimit into item 1 of it
put rLimit into item 3 of it
put rect of bkgnd btn "Regional Chart shadow" into temp
put lLimit + 5 into item 1 of temp
put rLimit + 5 into item 3 of temp
set the rect of bkgnd btn "Regional Chart" to it
set the rect of bkgnd btn "Regional Chart shadow" to temp
show bkgnd btn "Regional Chart"
show bkgnd btn "Regional Chart shadow"
set lockscreen to false
set lockscreen to true
-- Calculate the values needed for graphing the data
put (item 3 of it - item 1 of it) - margin into frameWidth
put round (frameWidth / dataCount) into horizStep
put round (horizStep * 3/4) into width
put horizStep - width - margin into marginDiff
if marginDiff > 1 then add round (marginDiff / 2) to margin
put item 1 of it + margin into horiz
put item 4 of it - margin into bottom
put item 4 of it - item 2 of it - botMargin into frameHeight
put item 4 of it - botMargin into barBottom
-- Set up generic script for rep bar buttons.
put "on mouseUp" & return & "goRepCard short name of me" & return & "end mouseUp" into btnScript
put item 1 of rect of bkgnd btn "Regional Chart" + margin into horiz
-- Make buttons. These coincide with the bars of the graph.
choose button tool
put empty into centersList
add sideMargin to lLimit
repeat with i = 1 to dataCount
put round (item i of regionPercents * frameHeight / 100) into barHeight
if barBottom-barHeight < graphStopsHere then adjustFrameHeight
drag from 10,10 to 50,50 with commandKey -- to ensure adequate size
set rect of card btn i to lLimit,barBottom-barHeight, lLimit+barWidth,barBottom
set autoHilite of card btn i to true
put "Rep" && item i of repNums into repCardName
set name of card button i to repCardName
set script of card button i to btnScript
put (lLimit+(barWidth div 2)) & "," after centersList
add (barWidth + sideMargin) to lLimit
end repeat
choose browse tool
put empty into last char of centersList
hideStatus
--prepare to draw the bar graph
reset paint
set lineSize to 1
set filled to true
set textAlign to Center
set textFont to Geneva
--set textStyle to Bold
set textSize to 9 -- This won't work w/ >5 dataItems
put 0 into regionTotal
set lockScreen to false
--draw the bars
repeat with i = 1 to dataCount
set cursor to busy
DrawSingleBar rect of card btn i
put item i of regionSubtotals into dataItem
add dataItem to regionTotal
put addComma (dataItem) into dataItem
choose text tool
put item i of centersList into center
click at center, 320
set textStyle to Bold
type dataItem
click at center, 332
set textStyle to Plain
type item i of regionReps
end repeat
-- Make fields for the percentages
set lockScreen to true
repeat with i = 1 to dataCount
set cursor to busy
MakeField i,barBottom,item i of centersList
set name of card field i to "Rep" && item i of repNums
put formatPercent (item i of regionPercents) into card field i
end repeat
choose browse tool
set lockScreen to false
-- Calculate % of quota for the region
put addComma (regionTotal) into field "Region Sales"
-- The regional quota was just retrieved, so it's current
--put field "Item Offset" into itemNum
put word 2 of short name of this card into officeNum
put itemOffset(officeNum,field "office_nr" of card "All Regions") into itemNum
put item itemNum of AllRegionQuotas () into regionQuota
put addComma (regionQuota) & " >>" into field "Region Quota"
put deleteComma (regionQuota) into regionQuota
put regionTotal / regionQuota * 100 into percent
-- Draw the single bar chart for the regional data
put rect of bkgnd btn "Regional Sales YTD" into graphArea
DrawLargeBar graphArea,percent
set lockScreen to true
put item 3 of graphArea - item 1 of graphArea into width
MakeField dataCount+1, item 4 of graphArea - margin, round (item 1 of graphArea + width/2 )
put formatPercent (percent) into card field (dataCount+1)
showClickMessage
choose browse tool
end DoGraph
on UpdateOneBar repNum
--given a rep number, redraw the bar corresponding to that
--rep’s sales and the region combined bar
--first double check that bar exists
put empty into btnNum
put number of card buttons into numReps
repeat with i = 1 to numReps
if repNum <> word 2 of the short name of card button i
then next repeat
put i into btnNum
end repeat
if btnNum is empty then
-- put "Cannot update the chart for Rep" && repNum
exit UpdateOneBar
end if
--start setting up for draw that single bar
show field "Status Backdrop"
show field "Status"
put "Stand by… Updating the bar chart" into bkgnd field "Status"
set cursor to 4
set lockScreen to true
put regionNumber (the short name of this card) into regionNum
put RegionalFigures(regionNum) into regionSubtotals
put RegionalPercents(regionNum) into regionPercents
put RegionalNames(regionNum) into regionReps
put RegionalRepNums(regionNum) into repNums
--get the rep’s data
get itemOffset(repNum,repNums)
put item it of regionReps into myName
put item it of regionPercents into myPercent
put item it of regionSubtotals into mySales
--get the region’s data
get itemOffset(regionNum,AllRegionNums())
put item it of AllRegionQuotas() into regionQuota
put item it of AllRegionSales() into regionSales
put 100*regionSales/regionQuota into regionPercent
get the rect of card button btnNum
put item 1 of it into L
put item 2 of it into T
put item 3 of it into R
put item 4 of it into B
get the rect of bkgnd btn "Regional Sales YTD"
put item 1 of it into ML
put item 2 of it into MT
put item 3 of it into MR
put item 4 of it into MB
get rect of background button "Regional Chart"
put item 2 of it into frameTop
put item 4 of it into frameBottom
reset paint
--clear out the old bar
choose select tool
drag from L,T to R,B
type NumToChar(8) --backspace to erase
drag from ML,0 to MR,MB
type NumToChar(8)
--clear out the caption
drag from L-4,frameBottom+7 to R+4,342
type NumToChar(8)
put empty into field "Region Sales"
--clear out the percentage field
put empty into card field btnNum
put empty into card field (numReps + 1)
put empty into bkgnd field "Status"
hide bkgnd field "Status"
hide field "Status Backdrop"
set lockScreen to false
--redraw the bars
set lineSize to 1
set pattern to 12
set filled to true
put round(B - (myPercent * (B - frameTop) / 100)) into T
set the rect of card button btnNum to L,T,R,B
choose rectangle tool
drag from L,T to R,B with optionKey
set filled to true
doMenu "Select"
doMenu "Opaque"
set pattern to 22
doMenu Fill
wait 10
set pattern to 14
doMenu Fill
DrawLargeBar rect of bkgnd btn "Regional Sales YTD",regionPercent
--put in the caption
choose text tool
set textFont to Geneva
set textSize to 9 -- This won't work w/ >5 rep’s
set textAlign to Center
set textStyle to Bold
get (L + R) div 2
click at it, 320
type addComma(mySales)
click at it, 332
set textStyle to Plain
type myName
put addComma(regionSales) into field "Region Sales"
--put in the percentage
put formatPercent(myPercent) into card field btnNum
put formatPercent(regionPercent) into card field (numReps + 1)
put addComma (regionQuota) & " >>" into field "Region Quota"
put the short date && the short time into field "Time & Date"
choose browse tool
end UpdateOneBar
on MakeField i, bottom, center
choose field tool
show field "% Template"
select bkgnd field "% Template"
doMenu "Copy Field"
hide field "% Template"
doMenu "Paste Field"
set the loc of card field i to center, bottom-11
end MakeField
on ClearOutCard xmax, ymin, itemCount
set lockScreen to true
choose select tool
drag from 0, ymin to 512, 342
doMenu "Clear Picture"
drag from xmax, 342 to 512, 0
doMenu "Clear Picture"
choose button tool
repeat with i = the number of card buttons down to 1
select card btn i
doMenu "Clear Button"
end repeat
choose field tool
repeat with i = the number of card fields down to 1
select card field i
doMenu "Clear Field"
end repeat
choose browse tool
put empty into field "Region Sales"
hide bkgnd btn "Regional Chart"
hide bkgnd btn "Regional Chart shadow"
set lockScreen to false
end ClearOutCard
on goRepCard repCardName
set cursor to 4
lock screen
go to card repCardName
unlock screen with iris open
end goRepCard
on showClickMessage
put "Click a bar below for individual data" into field "Status"
show field "Status Backdrop"
show field "Status"
end showClickMessage
on hideStatus
hide field "Status"
hide field "Status Backdrop"
put empty into field "Status"
end hideStatus
on openCard
global updateThisBar
if updateThisBar is not empty then
UpdateOneBar updateThisBar
put empty into updateThisBar
end if
showClickMessage
pass openCard
end openCard
on closeCard
hideStatus
end closeCard
-- part 14 (button)
-- low flags: 00
-- high flags: 0001
-- rect: left=0 top=0 right=98 bottom=179
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Map
----- HyperTalk script -----
on mouseUp
visual effect iris close
go to card "Map of Regions"
end mouseUp
-- part 1 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=14 top=97 right=116 bottom=141
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 16
-- part name: Labels
-- part 2 (field)
-- low flags: 01
-- high flags: 2002
-- rect: left=183 top=5 right=53 bottom=391
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 20
-- text size: 18
-- style flags: 0
-- line height: 20
-- part name: Title1
----- HyperTalk script -----
on mouseUp
pass mouseUp
end mouseUp
-- part 3 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=14 top=111 right=130 bottom=141
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 16
-- part name: Region Data
-- part 25 (button)
-- low flags: 00
-- high flags: 4002
-- rect: left=87 top=206 right=306 bottom=402
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Regional Chart shadow
-- part 4 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=410 top=317 right=339 bottom=499
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Sales Label
-- part 5 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=288 top=76 right=100 bottom=407
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 65535
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 15
-- part name: Region Quota
-- part 6 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=217 top=76 right=101 bottom=307
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 15
-- part name: RegLabel
-- part 26 (button)
-- low flags: 00
-- high flags: 4002
-- rect: left=412 top=95 right=306 bottom=502
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Regional Sales YTD shadow
-- part 7 (button)
-- low flags: 00
-- high flags: 0002
-- rect: left=82 top=201 right=301 bottom=397
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Regional Chart
-- part 8 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=410 top=303 right=328 bottom=499
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 15
-- part name: Region Sales
-- part 22 (button)
-- low flags: 00
-- high flags: 0002
-- rect: left=407 top=89 right=301 bottom=497
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Regional Sales YTD
-- part 15 (button)
-- low flags: 00
-- high flags: 4000
-- rect: left=182 top=4 right=54 bottom=392
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Map
----- HyperTalk script -----
on mouseUp
set the hilite of the target to true
visual effect iris close
go to card "Map of Regions"
end mouseUp
-- part 18 (field)
-- low flags: 01
-- high flags: 2004
-- rect: left=90 top=132 right=170 bottom=398
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Status Backdrop
-- part 19 (field)
-- low flags: 81
-- high flags: 2002
-- rect: left=73 top=30 right=48 bottom=124
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 9
-- style flags: 256
-- line height: 12
-- part name: % Template
----- HyperTalk script -----
on mouseUp
goRepCard short name of me
end mouseUp
-- part 20 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=197 top=53 right=71 bottom=400
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 13
-- part name: Time & Date Label
-- part 21 (field)
-- low flags: 81
-- high flags: 2002
-- rect: left=19 top=30 right=48 bottom=70
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 9
-- style flags: 256
-- line height: 12
-- part name: item offset
-- part 23 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=90 top=137 right=167 bottom=397
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 12
-- style flags: 256
-- line height: 16
-- part name: Status
-- part 24 (field)
-- low flags: 01
-- high flags: 2000
-- rect: left=252 top=51 right=76 bottom=387
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 15
-- part name: Time & Date
-- part 28 (field)
-- low flags: 00
-- high flags: 0000
-- rect: left=309 top=97 right=116 bottom=394
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 16
-- part name: Label 2
-- part 29 (field)
-- low flags: 00
-- high flags: 0000
-- rect: left=160 top=97 right=116 bottom=278
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 0
-- line height: 16
-- part name: Label 3
-- part 30 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=160 top=111 right=130 bottom=278
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 16
-- part name: Region Data 3
-- part 31 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=309 top=111 right=130 bottom=394
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 256
-- line height: 16
-- part name: Region Data 2
-- part 32 (button)
-- low flags: 00
-- high flags: 8000
-- rect: left=0 top=80 right=95 bottom=179
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 3
-- text size: 10
-- style flags: 512
-- line height: 13
-- part name: Return to the U. S. Map